<!DOCTYPE html>
<title>HTMLCollection edge cases</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test"><img><img id=foo><img id=foo></div>
<script>
test(function() {
  var container = document.getElementById("test");
  var result = container.children.item("foo");
  assert_true(result instanceof Element, "Expected an Element.");
  assert_false(result.hasAttribute("id"), "Expected the IDless Element.")
})
test(function() {
  var container = document.getElementById("test");
  var list = container.children;
  var result = [];
  for (var p in list) {
    if (list.hasOwnProperty(p)) {
      result.push(p);
    }
  }
  assert_array_equals(result, ['0', '1', '2']);
  result = Object.getOwnPropertyNames(list);
  assert_array_equals(result, ['0', '1', '2', 'foo']);
});
</script>
